const jwt = require('jsonwebtoken')
const secret = 'srlt';
exports.generateToken = (id) => {
    let payload = { id: id, time: new Date() }

    let token = jwt.sign(payload, secret, { expiresIn: 60 * 60 * 24 * 120 })
    return token
}

exports.verifyToken = (e) => {
    let payload
    jwt.verify(e, secret, (err, res) => {
        if (err) {
            payload = 0
        } else {
            payload = 1
        }
    })
    return payload
}